<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../css/pintuer.css">
    <link rel="stylesheet" href="../css/bootstrap.css">

    <script src="../js/jquery-3.4.1.min.js"></script>
    <script src="../js/popper.min.js"></script>
    <script src="../js/bootstrap-table1.15.3.js"></script>
    <script src="../js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../js/bootstrap-min-4.3.1.js"></script>
    <script src="../js/pintuer.js"></script>
    <script src="../js/initMain.js"></script>
    <script type="text/javascript">
        function initTable(){
            $("#tableInfo").bootstrapTable({
                method:"post",
                contentType:"application/json",
                url:"/sysMenus/queryAllMenus.action",
                //设置交替行样式
                striped:true,
                //初始显示页数
                pageNum:1,
                //是否显示分页
                pagination:true,
                //设置是服务端分页还是客户端分页
                sidePagination:"server",
                //页大小
                pageSize:5,
                //分页列表
                pageList: [5,6,10],
                //上传到服务器的参数
                queryParams:function (data) {
                    return{
                        //计算页号，当前号
                        pageNum:(data.offset/data.limit)+1,
                        //计算页大小
                        pageSize: data.limit,
                    }
                },
                columns:[

                    {title:"菜单ID",field:"id",align:"center"},
                    {title:"菜单名称",field:"name",align:"center"},
                    {title:"父菜单",field:"parentId",align:"center"},
                    {title:"菜单URL",field:"linkUrl",align:"center"},
                    {title:"状态",field:"status",align:"center",formatter:function (value,row,index) {
                        if(value==1||value=="1"){
                            return "正常";
                        }else {
                            return "异常";
                        }
                    }},
                ],onLoadSuccess:function(){
                    $.ajax({
                        url:"/sysMenus/queryAllMenus1.action",
                        type:"post",
                        success:function (data) {
                            var allTableData = $("#tableInfo tbody tr");
                            for(var i = 0; i < allTableData.length; i++) {
                                for(var j=0;j<data.length;j++){
                                        var menu=data[j];
                                        if(menu.id == $("#tableInfo tbody tr").eq(i).children().eq(2).text() ) {
                                            // alert(menu.id);
                                            // alert($("#tableInfo tbody tr").eq(j).children().eq(2).text() );
                                            $("#tableInfo tbody tr").eq(i).children().eq(2).text( menu.name );
                                        }

                                }
                                if( $("#tableInfo tbody tr").eq(i).children().eq(2).text()<0){
                                    $("#tableInfo tbody tr").eq(i).children().eq(2).text("-");
                                }
                            }
                        }
                    })



                }

            })
        }
        $(function () {
                initTable();
        })


    </script>
</head>
<body>
    <table id="tableInfo"></table>

</body>
</html>